package com.jdzy.student.controller;

import com.jdzy.model.common.vos.Result;
import com.jdzy.model.student.dtos.ThesisDeleteDto;
import com.jdzy.model.student.dtos.ThesisDto;
import com.jdzy.model.student.dtos.ThesisSearchDto;
import com.jdzy.student.service.ThesisService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("api/thesis")
@Api(value = "论文的controller类")
public class ThesisController {
    @Autowired
    private ThesisService thesisService;

    /**
     * 根据学号获取论文信息
     * @param stuId
     * @return
     */
    @PostMapping("getThesisByUserId/{stuId}/{page}/{size}")
    public Result getThesisByUserId(@PathVariable String stuId, @PathVariable Integer page, @PathVariable Integer size
    , @RequestBody ThesisSearchDto thesisSearchDto){
        log.info("根据学号获取论文信息,参数:{},{},{},{}",stuId,page,size,thesisSearchDto);
        return thesisService.getThesisByUserId(stuId,page,size,thesisSearchDto);
    }

    /**
     * 删除论文信息
     * @param stuId
     * @param thesisDeleteDto
     * @return
     */
    @DeleteMapping("deleteThesis/{stuId}")
    public Result deleteThesis(@PathVariable String stuId, @RequestBody ThesisDeleteDto thesisDeleteDto){
        log.info("删除论文信息,参数:{},{}",stuId,thesisDeleteDto);
        return thesisService.deleteThesis(stuId,thesisDeleteDto);
    }

    /**
     * 新增论文信息
     * @param thesisDto
     * @return
     */
    @PostMapping("saveThesis")
    public Result saveThesis(@RequestBody ThesisDto thesisDto){
        log.info("新增论文信息,参数:{}",thesisDto);
        return thesisService.saveThesis(thesisDto);
    }

    /**
     * 修改论文信息
     * @param thesisDto
     * @return
     */
    @PostMapping("updateThesis")
    public Result updateThesis(@RequestBody ThesisDto thesisDto){
        log.info("修改论文信息,参数:{}",thesisDto);
        return thesisService.updateThesis(thesisDto);
    }
}
